package org.jeecg.modules.performance.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.aspect.annotation.AutoLog;
import org.jeecg.common.system.base.controller.JeecgController;
import org.jeecg.modules.performance.Model.PerformanceConfigModel;
import org.jeecg.modules.performance.Model.UserPerforModel;
import org.jeecg.modules.performance.entity.PerformanceConfig;
import org.jeecg.modules.performance.entity.UserPerformance;
import org.jeecg.modules.performance.service.IPerformanceConfigService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

/**
* @Description: 绩效
* @Author: jeecg-boot
* @Date:   2021-04-14
* @Version: V1.0
*/
@Slf4j
@Api(tags="绩效")
@RestController
@RequestMapping("/performance/performanceUser")
public class PerformanceUserController extends JeecgController<PerformanceConfig, IPerformanceConfigService> {
   @Autowired
   private IPerformanceConfigService performanceConfigService;


   @AutoLog(value = "绩效-绩效配置页面")
   @ApiOperation(value="绩效-绩效配置页面", notes="绩效-绩效配置页面")
   @GetMapping(value = "/list")
   public Result<?> queryPageList(UserPerforModel userPerforModel,
                                  @RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
                                  @RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
                                  HttpServletRequest req) throws IOException {
       Page<UserPerforModel> page = new Page<UserPerforModel>(pageNo, pageSize);
       IPage<UserPerforModel> pageList = performanceConfigService.getUserPerformanceList(page, userPerforModel) ;

       return Result.ok(pageList);
   }


   /**
    * 编辑
    *
    * @param userPerforModel
    * @return
    */
   @AutoLog(value = "绩效-编辑")
   @ApiOperation(value="绩效-编辑", notes="绩效-编辑")
   @PutMapping(value = "/edit")
   public Result<?> edit( @RequestBody UserPerforModel userPerforModel) {
      performanceConfigService.setUserPerformances( userPerforModel);
       return Result.ok("编辑成功!");
   }









}
